package co.com.services.agendas;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.AgendaDTO;
import co.com.smart.session.DelegateContextEJB;


@Path("/SmartAgendaServices")
public class AgendaServices {
	@GET
	@Path("/getAllAgenda")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getAgenda() throws NamingException {
		return Response.ok(DelegateContextEJB.getAgendaBeanLocal().consultarAllAgenda())
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@POST
	@Path("/getAgendaId")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getAgendaId(AgendaDTO json) throws NamingException {
		return Response.ok(DelegateContextEJB.getAgendaBeanLocal().consultarAgendaId(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/setAgenda")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setAgenda( AgendaDTO json){ 
		return Response.ok(DelegateContextEJB.getAgendaBeanLocal().insertarAgenda(json))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
				.build();
	}

	@PUT
	@Path("/editAgenda")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setEditAgenda(AgendaDTO json){ 
		return Response.ok(DelegateContextEJB.getAgendaBeanLocal().editAgenda(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/removeAgenda")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setRemoveAgenda(AgendaDTO json){ 
		return Response.ok(DelegateContextEJB.getAgendaBeanLocal().removeAgenda(json, true))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}




}
